#include<iostream>
#define ll long long

using namespace std;

ll find(int num)
{
	ll l = 1; ll r = 25819;
	while(l < r)
	{
		int mid = (l + r + 1)  / 2;
		if(mid * (3 * mid + 1) / 2 <= num) l = mid;
		else r = mid - 1;
	}
	return l * (l * 3 + 1) / 2;
}

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		ll cnt = 0;
		while(n > 1)
		{
			cnt++;
			n -= find(n);
		}
		cout<<cnt<<endl;
	}	
	return 0;
 } 
 
